﻿@model IEnumerable<PersonalFinances.Models.Note>
@{
    ViewBag.Title = "ShowMonth";
}


<h2>ShowMonth</h2>

<div id="mainBody">
@{var date = Model.FirstOrDefault();
  var days = new List<DateTime>();
  for (int i = 0; i != DateTime.DaysInMonth(date.Date.Year, date.Date.Month); i++)
  {
      days.Add(new DateTime(date.Date.Year, date.Date.Month, i + 1));
  }
  
<div id="monthGeneralDetails">
<table border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td>
            <div class="display-label">Debitos</div>
            <div class="display-field">
                <!--Html.DisplayFor(model => model.Debits)-->
            </div>
        </td>
        <td>
            <div class="display-label">Créditos</div>
            <div class="display-field">
                <!--Html.DisplayFor(model => model.Credits)-->
            </div>
        </td>
        <td>
            <div class="display-label">PrevBalance</div>
            <div class="display-field">
                <!--Html.DisplayFor(model => model.PrevBalance)-->
            </div>
        </td>
        <td>
            <div class="display-label">Name</div>
            <div class="display-field">
                @Html.DisplayFor(model => date.Date)
            </div>
        </td>
    </tr>
</table>
</div>

<div id="dayDetail">
</div>
  
<div id="listDays">
<table border="10" cellpadding="0" cellspacing="0">
    <tr>
        <td>Seg</td>
        <td>Ter</td>
        <td>Qua</td>
        <td>Qui</td>
        <td>Sex</td>
        <td>Sab</td>
        <td>Dom</td>
    </tr>
    <tr>
    
@foreach (var weekDay in Enum.GetValues(typeof(System.DayOfWeek)))
{

    if ((int)weekDay < (int)days.OrderBy(x => x.Date).FirstOrDefault().DayOfWeek)
    {
        <td>
        </td>
    }
}
@foreach (var item in days.OrderBy(x => x.Date))
{
    if (item.Date.DayOfWeek == DayOfWeek.Sunday && item.Day != 1)
    {
    @:</tr>
    @:<tr>
    }
        <td>
            @Ajax.ActionLink(item.Day + "/" + item.Month, "ShowDay", new { day = item }, new AjaxOptions { HttpMethod = "Get", UpdateTargetId = "dayDetail"})
        </td>
}
    </tr>
</table>
</div>
<div id ="footer">
<p>
    FOOTER
</p> 
</div>
}

</div>